home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #5 & #6
/
Amiga Plus CD - 1995 - No. 5 and 6.iso
/
pd
/
netz
/
term
/
extras
/
source
/
term-source.lha
/
SpeechPanel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-17
|
9KB
|
376 lines
/*
** SpeechPanel.c
**
** Editing panel for speech configuration
**
** Copyright © 1990-1995 by Olaf `Olsen' Barthel
** All Rights Reserved
*/
#include "termGlobal.h"
enum { GAD_RATE=1,GAD_PITCH,GAD_FREQUENCY,GAD_VOLUME,GAD_SEX,GAD_ENABLED,GAD_SPEAK,
GAD_USE,GAD_LOAD,GAD_SAVE,GAD_CANCEL
};
STATIC LONG __saveds
VolumeDisplay(struct Gadget *SomeGadget,WORD Level)
{
return((100 * (LONG)Level) / MAXVOL);
}
VOID
SpeechPanel()
{
struct LayoutHandle *Handle;
struct SpeechConfig PrivateConfig;
ULONG OldCRC;
OldCRC = DoCRC(&SpeechConfig,sizeof(SpeechConfig));
CopyMem(&SpeechConfig,&PrivateConfig,sizeof(struct SpeechConfig));
if(Handle = LT_CreateHandleTags(Window -> WScreen,
LH_LocaleHook, &LocaleHook,
LH_ExitFlush, FALSE,
TAG_DONE))
{
struct Window *PanelWindow;
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, VERTICAL_KIND,
LA_LabelID, MSG_V36_0185,
TAG_DONE);
{
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, SliderType,
LA_LabelID, MSG_SPEECHPANEL_RATE_GAD,
LA_WORD, &SpeechConfig . Rate,
LA_Chars, 20,
LA_ID, GAD_RATE,
GTSL_Min, MINRATE,
GTSL_Max, MAXRATE,
GTSL_LevelFormat, LocaleBase ? "%lD" : "%ld",
TAG_DONE);
LT_New(Handle,
LA_Type, SliderType,
LA_LabelID, MSG_SPEECHPANEL_PITCH_GAD,
LA_WORD, &SpeechConfig . Pitch,
LA_ID, GAD_PITCH,
GTSL_Min, MINPITCH,
GTSL_Max, MAXPITCH,
GTSL_LevelFormat, LocaleBase ? "%lD" : "%ld",
TAG_DONE);
LT_New(Handle,
LA_Type, SliderType,
LA_LabelID, MSG_SPEECHPANEL_FREQUENCY_GAD,
LA_LONG, &SpeechConfig . Frequency,
LA_ID, GAD_FREQUENCY,
GTSL_Min, MINFREQ,
GTSL_Max, MAXFREQ,
GTSL_LevelFormat, LocaleBase ? "%lD" : "%ld",
TAG_DONE);
LT_New(Handle,
LA_Type, SliderType,
LA_LabelID, MSG_SPEECHPANEL_VOLUME_GAD,
LA_BYTE, &SpeechConfig . Volume,
LA_ID, GAD_VOLUME,
GTSL_Min, MINVOL,
GTSL_Max, MAXVOL,
GTSL_LevelFormat, "%ld%%",
GTSL_DispFunc, VolumeDisplay,
TAG_DONE);
LT_New(Handle,
LA_Type, MX_KIND,
LA_LabelID, MSG_SPEECHPANEL_SEX_GAD,
LA_BYTE, &SpeechConfig . Sex,
LA_ID, GAD_SEX,
LAMX_FirstLabel, MSG_SPEECHPANEL_MALE_TXT,
LAMX_LastLabel, MSG_SPEECHPANEL_FEMALE_TXT,
TAG_DONE);
LT_New(Handle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_SPEECHPANEL_SPEECH_ENABLED_GAD,
LA_BYTE, &SpeechConfig . Enabled,
LA_ID, GAD_ENABLED,
LA_ExtraSpace, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, XBAR_KIND,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_SPEECHPANEL_SPEAK_GAD,
LA_ID, GAD_SPEAK,
LA_ExtraFat, TRUE,
GA_Disabled, !SpeechConfig . Enabled,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type,VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, XBAR_KIND,
LAXB_FullSize, TRUE,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,LA_Type,HORIZONTAL_KIND,
LAGR_SameSize, TRUE,
LAGR_Spread, TRUE,
TAG_DONE);
{
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_GLOBAL_USE_GAD,
LA_ID, GAD_USE,
LABT_ReturnKey, TRUE,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_GLOBAL_LOAD_GAD,
LA_ID, GAD_LOAD,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_GLOBAL_SAVE_GAD,
LA_ID, GAD_SAVE,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_GLOBAL_CANCEL_GAD,
LA_ID, GAD_CANCEL,
LABT_EscKey, TRUE,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_EndGroup(Handle);
}
if(PanelWindow = LT_Layout(Handle,LocaleString(MSG_SPEECHPANEL_SPEECH_PREFERENCES_TXT),NULL,0,0,IDCMP_CLOSEWINDOW,0,
LAWN_HelpHook, &GuideHook,
LAWN_Parent, Window,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_DragBar, TRUE,
WA_RMBTrap, TRUE,
WA_Activate, TRUE,
TAG_DONE))
{
struct IntuiMessage *Message;
BOOLEAN Done = FALSE;
ULONG MsgClass,
MsgQualifier;
UWORD MsgCode;
struct Gadget *MsgGadget;
UBYTE DummyBuffer[MAX_FILENAME_LENGTH],
*DummyChar;
struct FileRequester *FileRequest;
BYTE OldEnglish = English;
GuideContext(CONTEXT_SPEECH);
PushWindow(PanelWindow);
do
{
if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
{
CopyMem(&PrivateConfig,&SpeechConfig,sizeof(struct SpeechConfig));
SpeechSetup();
break;
}
while(Message = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort))
{
MsgClass = Message -> Class;
MsgQualifier = Message -> Qualifier;
MsgCode = Message -> Code;
MsgGadget = (struct Gadget *)Message -> IAddress;
GT_ReplyIMsg(Message);
LT_HandleInput(Handle,MsgQualifier,&MsgClass,&MsgCode,&MsgGadget);
if(MsgClass == IDCMP_CLOSEWINDOW)
{
CopyMem(&PrivateConfig,&SpeechConfig,sizeof(struct SpeechConfig));
SpeechSetup();
Done = TRUE;
}
if(MsgClass == IDCMP_GADGETUP)
{
switch(MsgGadget -> GadgetID)
{
case GAD_ENABLED:
LT_SetAttributes(Handle,GAD_SPEAK,GA_Disabled,!MsgCode,TAG_DONE);
break;
case GAD_USE:
Done = TRUE;
break;
case GAD_CANCEL:
CopyMem(&PrivateConfig,&SpeechConfig,sizeof(struct SpeechConfig));
SpeechSetup();
Done = TRUE;
break;
case GAD_LOAD:
SplitFileName(LastSpeech,&DummyChar,DummyBuffer);
LT_LockWindow(PanelWindow);
if(FileRequest = GetFile(PanelWindow,LocaleString(MSG_SPEECHPANEL_LOAD_SPEECH_SETTINGS_TXT),DummyBuffer,FilePart(LastSpeech),DummyBuffer,"#?.prefs",FALSE,FALSE,FALSE,LocaleString(MSG_GLOBAL_LOAD_TXT),TRUE))
{
if(!ReadIFFData(DummyBuffer,&SpeechConfig,sizeof(struct SpeechConfig),ID_SPEK))
ShowError(PanelWindow,ERR_LOAD_ERROR,IoErr(),DummyBuffer);
else
{
strcpy(LastSpeech,DummyBuffer);
LT_SetAttributes(Handle,GAD_RATE,
GTSL_Level,SpeechConfig . Rate,
TAG_DONE);
LT_SetAttributes(Handle,GAD_PITCH,
GTSL_Level,SpeechConfig . Pitch,
TAG_DONE);
LT_SetAttributes(Handle,GAD_FREQUENCY,
GTSL_Level,SpeechConfig . Frequency,
TAG_DONE);
LT_SetAttributes(Handle,GAD_VOLUME,
GTSL_Level,SpeechConfig . Volume,
TAG_DONE);
LT_SetAttributes(Handle,GAD_SEX,
GTCY_Active,SpeechConfig . Sex,
TAG_DONE);
LT_SetAttributes(Handle,GAD_ENABLED,
GTCB_Checked,SpeechConfig . Enabled,
TAG_DONE);
LT_SetAttributes(Handle,GAD_SPEAK,
GA_Disabled, SpeechConfig . Enabled == FALSE,
TAG_DONE);
SpeechSetup();
SpeechChanged = FALSE;
OldCRC = DoCRC(&SpeechConfig,sizeof(SpeechConfig));
}
FreeAslRequest(FileRequest);
}
LT_UnlockWindow(PanelWindow);
break;
case GAD_SAVE:
SplitFileName(LastSpeech,&DummyChar,DummyBuffer);
LT_LockWindow(PanelWindow);
if(FileRequest = GetFile(PanelWindow,LocaleString(MSG_SPEECHPANEL_SAVE_SPEECH_SETTINGS_TXT),DummyBuffer,FilePart(LastSpeech),DummyBuffer,"#?.prefs",TRUE,FALSE,FALSE,LocaleString(MSG_GLOBAL_SAVE_TXT),TRUE))
{
if(!WriteIFFData(DummyBuffer,&SpeechConfig,sizeof(struct SpeechConfig),ID_SPEK))
ShowError(PanelWindow,ERR_SAVE_ERROR,IoErr(),DummyBuffer);
else
{
strcpy(LastSpeech,DummyBuffer);
SpeechChanged = FALSE;
OldCRC = DoCRC(&SpeechConfig,sizeof(SpeechConfig));
}
FreeAslRequest(FileRequest);
}
LT_UnlockWindow(PanelWindow);
break;
case GAD_SPEAK:
SpeechSetup();
English = TRUE;
Say(LocaleString(MSG_SPEECHPANEL_THIS_IS_TERM_SPEAKING_TXT));
English = OldEnglish;
break;
}
}
}
}
while(!Done);
PopWindow();
}
LT_DeleteHandle(Handle);
}
SpeechChanged |= (OldCRC != DoCRC(&SpeechConfig,sizeof(SpeechConfig)));
}